#include <stdio.h>

int main0()
{
    // 向一个char的数组输出一个字符串
    char a[100] = { 0 };
    int i = 1000;
    sprintf(a, "%s%d%x", "hello world", i, i);
    printf("%s\n", a);
    return 0;
}

int main1()
{
    char a[100] = "56+792";
    int i;
    int j;
    sscanf(a, "%d+%d", &i, &j);
    printf("%d + %d = %d\n", i, j, i + j);
    return 0;
}

int main()
{
    char a[100] = "56*92=";
    int i, j;
    char c;
    sscanf(a, "%d%c%d=", &i, &c, &j);
    //printf("%d, %c, %d\n", i, c, j);
    int res = 0;
    switch(c)//swithc注意结尾要用break跳出循环
    {
        case '+':
            res = i + j;
            break;
        case '-':
            res = i - j;
            break;
        case '*':
            res = i * j;
            break;
        case '/':
            res = i / j;
            break;
        default:
            res = 0;
            break;
    }

    sprintf(a, "%d%c%d=%d", i, c, j, res);
    printf("%s\n", a);
    return 0;
}
